import { StateCreator } from 'zustand';

export type OutputStore = {
  outputText: string[],
  originOutputText: string[],
  getOutputText: () => string[];
  setOutputText: (text: string) => void;
  setOriginOutputText: (text: string) => void;
  clearOutputText: () => void;
  clearOriginOutputText: () => void;
};

export const outputStore: StateCreator<OutputStore> = (set, get) => ({
  outputText: [],
  originOutputText: [],
  setOutputText: (text) => set((state) => ({ outputText: [...state.outputText, text] })),
  clearOutputText: () => set(() => ({ outputText: [] })),
  clearOriginOutputText: () => set(() => ({ originOutputText: [] })),
  getOutputText: () => get().outputText,
  setOriginOutputText: (text) => set((state) => ({ originOutputText: [...state.originOutputText, text] }))
});
